import { reactive } from 'vue'
import { required } from '@/utils/formRules'
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
// 表单校验
export const rules = reactive({
  name: [required],
  sitePath: [required],
  siteDomain: [required],
  status: [required],
  sort: [required]
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: '上级站点',
    field: 'parentId',
    isTable: false
  },
  {
    label: '站点名称',
    field: 'name',
    isSearch: true,
    table: {
      treeNode: true,
      align: 'left'
    }
  },
  {
    label: '站点目录名',
    field: 'sitePath',
    isSearch: false
  },
  {
    label: '站点域名',
    field: 'siteDomain',
    isSearch: true
  },
  {
    label: '站点域名子域名',
    field: 'siteAliasDomain',
    isSearch: false,
    isTable: false
  },
  {
    label: 'SEO标题',
    field: 'seoTitle',
    isSearch: false,
    isTable: false
  },
  {
    label: 'SEO描述',
    field: 'seoDesc',
    isSearch: false,
    isTable: false
  },
  {
    label: 'SEO关键字',
    field: 'seoKey',
    isSearch: false,
    isTable: false
  },
  {
    label: '显示排序',
    field: 'sort'
  },
  {
    label: '站点状态',
    field: 'status',
    dictType: DICT_TYPE.CMS_STATUS_TYPE,
    dictClass: 'number'
  },
  {
    label: 'pc模板方案',
    field: 'pcSolution',
    isForm: false,
    isSearch: false,
    isTable: false
  },
  {
    label: 'h5模板方案',
    field: 'h5Solution',
    isForm: false,
    isSearch: false,
    isTable: false
  },
  {
    label: '创建时间',
    field: 'createTime',
    isForm: false,
    formatter: 'formatDate',
    search: {
      show: false,
      itemRender: {
        name: 'XDataTimePicker'
      }
    }
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
